﻿using System.Configuration;
using System.Web;
using SuCasa.Infrastructure;

namespace SuCasa.DataAccess{
    public class SuCasaContext{
        static string ContextKey = "SuCasaContext";

        public static SuCasaDbContext Instance
        {
            get{
                var result = (SuCasaDbContext)HttpContext.Current.Items[ContextKey];
                if (result == null){
                    result = new SuCasaDbContext(ConfigurationManager.ConnectionStrings["SucasaDB"].ToString());
                    HttpContext.Current.Items.Add(ContextKey, result);
                }
                return result;
            }
        } 
    }
}